﻿Imports MySql.Data.MySqlClient
Public Class SlotsGame
#Region "Drum counters"
    Dim drum1c As Integer = 0
    Dim drum2c As Integer = 0
    Dim drum3c As Integer = 0
#End Region
    Sub Spin() Handles spinbutton.Click ' Deals with starting the drums spinning.
        Dim bet As Integer
        drum1c = Int((Rnd() * 10) + 30) : drum2c = Int((Rnd() * 10) + 40) : drum3c = Int((Rnd() * 10) + 20)
        bet = betvalue.Text
        drum1timer.Enabled = True : drum2timer.Enabled = True : drum3timer.Enabled = True
        If (bet > 0) Then
            statsbox.betsvalue.Text = statsbox.betsvalue.Text + 1
            If (lblaviliablemoneyvalue.Text - bet >= 0) Then
                lblaviliablemoneyvalue.Text = "£" & lblaviliablemoneyvalue.Text - bet
                details.money = lblaviliablemoneyvalue.Text
                lblaviliablemoneyvalue.Text = "£" & lblaviliablemoneyvalue.Text - bet
                drum1timer.Enabled = True : drum2timer.Enabled = True : drum3timer.Enabled = True
                statsbox.totalbetvalue.Text = statsbox.totalbetvalue.Text + bet
            Else
                MsgBox("You Are Out of money")
                drum1timer.Enabled = False : drum2timer.Enabled = False : drum3timer.Enabled = False
            End If
        End If
    End Sub
    Sub Show_Stats() Handles OpenToolStripMenuItem.Click
        statsbox.Show()
    End Sub
    Sub Close_Stats() Handles CloseToolStripMenuItem.Click
        statsbox.Close()
    End Sub
    Sub Drum1_Spin() Handles drum1timer.Tick
        drum1.Text = Int(Rnd() * 10) ' pick numbers
        drum1c = drum1c - 1
        If drum1c <= 0 Then
            drum1timer.Enabled = False
            drum1.Text = Int(Rnd() * 10)
        End If
    End Sub
    Sub Drum2_Spin() Handles drum2timer.Tick ' Deals with spinning Drum2 and checking if there is a winner or not.
        drum2.Text = Int(Rnd() * 10) ' pick numbers
        drum2c = drum2c - 1

        If drum2c <= 0 Then
            drum2timer.Enabled = False
            drum2.Text = Int(Rnd() * 10)
            Dim bet As Integer
            bet = betvalue.Text
            If details.cheatmode = 2 Then
                drum3.Text = 7 : drum1.Text = 7 : drum2.Text = 7
            End If
            If (drum3.Text = 7 And drum1.Text = 7 And drum2.Text = 7) Then

                Beep()
                winner.Visible = True
                winner.Text = "WINNER"
                lblaviliablemoneyvalue.Text = lblaviliablemoneyvalue.Text + bet + (details.jack * bet)
                statsbox.winingsvalue.Text = statsbox.winingsvalue.Text + bet + (details.jack * bet)
                statsbox.Jackpotvalue.Text = statsbox.Jackpotvalue.Text + 1
                details.money = lblaviliablemoneyvalue.Text
                functions.Update_Money()
                lblaviliablemoneyvalue.Text = "£" & lblaviliablemoneyvalue.Text
                details.money = lblaviliablemoneyvalue.Text
                lblaviliablemoneyvalue.Text = "£" & lblaviliablemoneyvalue.Text + bet + (details.sw * bet)

            ElseIf (drum3.Text = 7 And drum1.Text = 7) Or (drum1.Text = 7 And drum2.Text = 7) Or (drum3.Text = 7 And drum2.Text = 7) Then

                Beep()
                winner.Text = "WINNER"
                winner.Visible = True
                lblaviliablemoneyvalue.Text = lblaviliablemoneyvalue.Text + bet + (details.sw * bet)
                statsbox.winingsvalue.Text = statsbox.winingsvalue.Text + bet + (details.sw * bet)
                details.money = lblaviliablemoneyvalue.Text
                functions.Update_Money()
                lblaviliablemoneyvalue.Text = "£" & lblaviliablemoneyvalue.Text
                lblaviliablemoneyvalue.Text = lblaviliablemoneyvalue.Text + bet + (details.sw * bet)
                statsbox.winingsvalue.Text = statsbox.winingsvalue.Text + bet + (details.sw * bet)
                details.money = lblaviliablemoneyvalue.Text
                lblaviliablemoneyvalue.Text = "£" & lblaviliablemoneyvalue.Text + bet + (details.sw * bet)
            Else

                winner.Visible = False
                statsbox.totallostvalue.Text = statsbox.totallostvalue.Text + bet
                functions.Update_Money()

            End If

            statsbox.totalwinvalues.Text = statsbox.totalwinvalues.Text + 1
            statsbox.totallosesvalue.Text = statsbox.totalwinvalues.Text + 1

        End If


    End Sub
    Sub Drum3_Spin() Handles drum3timer.Tick
        drum3.Text = Int(Rnd() * 10) ' pick numbers
        drum3c = drum3c - 1
        If drum3c <= 0 Then
            drum3timer.Enabled = False
            drum3.Text = Int(Rnd() * 10)
        End If
    End Sub
    Sub SlotsGame_Load() Handles MyBase.Load ' Updates how much money the user has able to bet with.
        lblaviliablemoneyvalue.Text = "£" & details.money
    End Sub
    Sub Slots_Closing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Welcome.panshout.Hide()
        Welcome.pangames.Show()
        Welcome.Height = 416
        Welcome.lblgamemoney.Text = "Game Money: £ " & details.money
        functions.Update_Money()
        details.money = lblaviliablemoneyvalue.Text
        Welcome.lblgamemoney.Text = "Game Money: £ " & details.money
    End Sub
    Sub Cheat_Key(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If cheatmode.Enabled = True Then
            If e.Alt And e.KeyCode = Keys.E Then
                If details.username = "burtybob" Or details.username = "Burtybob" _
                Or details.username = "ssaywell" Or details.username = "Ssaywell" Then
                    MsgBox("Cheat Mode Fully Activated")
                    details.cheatmode = 2
                    cheatmode.Enabled = False
                End If
            End If
        Else
            If e.Shift And e.KeyCode = Keys.F4 Then
                MsgBox("Cheat Mode Activated")
                details.cheatmode = 1
                cheatmode.Enabled = True
            End If
        End If
    End Sub
    Private Sub cheatmode_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cheatmode.Tick
        details.cheatmode = 0
        cheatmode.Enabled = False
    End Sub
End Class